package org.kaka.controller;

import org.kaka.dto.ContentDto;
import org.kaka.service.impl.ContentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/content")
public class ContentController extends BaseController{
    @Autowired
    private ContentServiceImpl contentService;

    @RequestMapping("/get")
    public Object get( ContentDto contentDto){
        return success(contentService.detail(contentDto));
    }

    @RequestMapping("/saveOrUpdate")
    public Object saveOrUpdate(@RequestBody ContentDto contentDto){
        if(contentDto.getId()==null){
            contentService.save(contentDto);
            return success("新增成功");
        }else{
            contentService.update(contentDto);
            return success("修改成功");
        }
    }

    @RequestMapping("/delete")
    public Object delete(Long id){
        contentService.delete(id);
        return success("删除成功");
    }


}
